package com.jsh;

import com.jsh.erp.utils.ComputerInfo;
import lombok.SneakyThrows;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;

@SpringBootApplication
@MapperScan("com.jsh.erp.datasource.mappers")
@ServletComponentScan
@EnableScheduling
@ComponentScan(value = "com.jsh")
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
        org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration.class
        ,org.activiti.spring.boot.SecurityAutoConfiguration.class})
public class ErpApplication extends SpringBootServletInitializer {



    @Override
    @SneakyThrows
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

        return application.sources(ErpApplication.class);
    }



    public static void main(String[] args) throws IOException {
        try {
            ConfigurableApplicationContext context = SpringApplication.run(ErpApplication.class, args);
            Environment environment = context.getBean(Environment.class);
            System.out.println("启动成功，后端服务API地址：http://" + ComputerInfo.getIpAddr() + ":"
                    + environment.getProperty("server.port") + "/jshERP-boot/doc.html");
            System.out.println("您还需启动前端服务，启动命令：yarn run serve 或 npm run serve，测试用户：jsh，密码：123456");

        }catch (Exception e){
            System.out.println(e);
        }

   }
}
